package cn.com.dingtek.genius.manager.server.utils;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;

public class MybatisPlusUtil {
    public static <T> QueryWrapper<T> customEqQuery(QueryWrapper<T> query, String key, Object value) {
        if (value == null) {
            return query;
        }

        if (query == null || query == Wrappers.emptyWrapper()) {
            return new QueryWrapper<T>().eq(key, value);
        }

        return query.eq(key, value);
    }

    public static <T> QueryWrapper<T> customLikeQuery(QueryWrapper<T> query, String key, Object value) {
        if (value == null) {
            return query;
        }

        if (query == null || query == Wrappers.emptyWrapper()) {
            return new QueryWrapper<T>().like(key, value);
        }

        return query.like(key, value);
    }
}
